package day0514;

public class Test6 {
    public static void main(String[] args) {


        int[] arr={1,3,5};
        long rs=add2(arr);
        System.out.println(rs);
    }

    public static long add2(int[] a){
        long sum=0;
        for(int   ele  :  a){
            sum= sum +ele;
        }
        return sum;
    }

    //可变参数的格式： int ... a (可以传入任意个参数)
    public static long add(int ... a){
        long sum=0;
        for(int element : a){
            sum= sum +element;
        }
        return sum;
    }

}
